package com.kkb.service.impl;

import com.kkb.mapper.UserChartMapper;
import com.kkb.pojo.ChartData;
import com.kkb.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

import static com.kkb.common.utils.DateUtils.parseDate;

/**
 * 用户相关service实现类
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserChartMapper userMapper;
    /**
     * 获取某个时间段内用户注册信息
     * @return
     */
    @Override
    public List<ChartData> getRegister() {
        //设置时间区间
        Date startTime = parseDate("2018-01-01 08:55:21");
        Date endDate = new Date();
        List<ChartData> chartData = userMapper.getChartData(startTime, endDate);
        return chartData;
    }

    @Override
    public List<ChartData> getConsumption() {
        //设置时间区间
        Date startTime = parseDate("2018-01-01 08:55:21");
        Date endDate = new Date();
        List<ChartData> consumption = userMapper.getConsumption(startTime, endDate);
        return consumption;
    }
}
